<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:widget="http://www.netvibes.com/ns/">
<head>
	<title>gWeather</title>
	<meta name="title" content="Google Weather Forecast" />
	<meta name="author" content="ehaagwlke" />
	<meta name="website" content="http://uwa-ow.googlecode.com/" />
	<meta name="description" content="Based on Google Weather Api, you can add as many cities as you can, and you counld see the weather for four days" />
	<meta name="version" content="alpha" />
	<meta name="keyword" content="weather forecast,tianqi,tq," />
	<meta name="thumbnail" content="http://news.bbc.co.uk/nol/shared/img/bbc_news_120x60.gif" />
	<meta name="screenshot" content="http://1821.img.pp.sohu.com.cn/images/2008/6/19/16/4/11b450290ea.jpg" />
	<meta name="debugMode" content="true" />
	
	<widget:preferences>
		<preference type="list" name="unit" label="unit" onchange="true">
			<option label="C" value="C" />
			<option label="F" value="F" />
		</preference>
	</widget:preferences>

	<script type="text/javascript">
		//<![CDATA[

			var apiUrl = 'http://www.google.com/ig/api?hl=zh-cn&weather=Beijing';
			
			widget.dataInt = function() {
				UWA.Data.getXml(
					apiUrl,
					widget.dataProcessor
					);
			}
		
			
		 
			widget.dataProcessor = function(xml){
				widget.body.empty();
				var root = xml.documentElement;
				if(root.firstChild){
					var w = root.firstChild;
						if(w.childNodes.length > 0){
							for(i = 0; i<w.childNodes.length; i++){
								if(w.childNodes[i].childNodes.length > 0){
									op += "<br />" + i+ " " + w.childNodes[i].tagName + ": <br />";
									for(j=0;j<w.childNodes[i].childNodes.length;j++){
										var n = w.childNodes[i].childNodes[j].tagName ? w.childNodes[i].childNodes[j].tagName : 'text node';
										var d = w.childNodes[i].childNodes[j].getAttribute('data');
										if(n == 'icon') d = 'http://www.google.com'+d;
										op += "&nbsp;&nbsp;&nbsp;&nbsp;"+j + " " + n + ": " + d + "<br />";
									}
								}else{
										op += '<br />The node "'+ w.childNodes[i].tagName +'" has now ChildNodes!';
								}
							}
							output = op;
						}else{
							output = 'The xml file is null';
						}
				}else{
					output = 'The xml file is null';
				}
				widget.setBody(output);
			}



			widget.onLoad = function(){
				widget.dataInt();
			}
			
			widget.onRefresh = function() {
				widget.body.empty();
				widget.setBody('<div class="content">Loading data.....</div>');
				widget.dataInt();
			}

			widget.onResize = function(){
				widget.body.empty();
				widget.setBody('<div class="content">Loading data.....</div>');
				widget.dataInt();
			}
			
		//]]>
	</script>
</head>
<body>
	<div class="content">Loading data.....</div>
</body>
</html>